<?php
/**
 * Created by JetBrains PhpStorm.
 * User: CACA-PC
 * Date: 26/12/2013
 * Time: 08:53
 * To change this template use File | Settings | File Templates.
 */
class Model_Banning extends CI_Model{
    public function __construct(){
        parent::__construct();
        $this->load->database();
    }
    // Dem tong so thanh vien bi cam
    public function count_all(){
        $url ="http://egov047.juddy.vn/api/Ban/GetAll";
        $json = file_get_contents($url);
        $json_data = json_decode($json,true);
        return count($json_data);
    }

    // Lay danh sach cac thanh vien bi cam tu web service
    public function listBanning(){
        $url ="http://egov047.juddy.vn/api/Ban/GetAll";
        $json = file_get_contents($url);
        $json_data = json_decode($json,true);
        return $json_data;
    }

    // Lay danh sach cac user web service
    public function getListUser(){
        $url ="http://egov047.juddy.vn/api/user/getall";
        $json = file_get_contents($url);
        $json_data = json_decode($json,true);
        return $json_data;
    }

    // lay danh sach thanh vien voi vi tri bat dau (start) va tong so record(record)
    public function listBan($record,$start){
        $url ="http://egov047.juddy.vn/api/Ban/GetAll";
        $json = file_get_contents($url);
        $json_data = json_decode($json,true);
        $list_data = array();
        $vitri = 1;
        $dem = 1;

        foreach ($json_data as $value)
        {
            if ($vitri = $start && $record >=$dem )
            {
                $list_data[] = $value;
                $dem++;
            }
            if ($dem > $record)
            {
                $dem=1;
                $vitri=1;
                break;
            }
            $vitri++;
        }
        return $list_data;
    }
}
?>
